﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Project.Controller;
using Project.Model;
using Project.View;

namespace Project.UserControls
{
    public partial class NieuwSpel_UserControl : UserControl
    {
        public NieuwSpel_UserControl()
        {
            InitializeComponent();
            this.Location = new Point(Location.X, Location.Y + SystemInformation.MenuHeight);
            this.spelers_UserControl1.Nuc = this;
        }

        private void startSpel_button_Click(object sender, EventArgs e)
        {
            List<SingleSpeler_UserControl> panels = this.spelers_UserControl1.Panels;
            Speler[] spelers = new Speler[panels.Count];
            for (int i = 0; i < panels.Count; i++)
            {
                SingleSpeler_UserControl panel = panels[i];
                if (panels.Count() != 4)
                {
                    spelers[i] = new Bot(panel.getNaam(), panel.Color, BotMoeilijkheid.MOEILIJK, null, 50);
                }
                else if (!panel.IsBot)
                {
                    spelers[i] = new Bot(panel.getNaam(), panel.Color, (BotMoeilijkheid)panel.getMoeilijkheid());
                }
                else
                {
                    spelers[i] = new Speler(panel.getNaam(), panel.Color);
                }
            }
            Form form = this.FindForm();
            form.Controls.Remove(((GUI)form).ControlProperty);
            Spel_UserControl suc = new Spel_UserControl(spelers, form);
            form.Controls.Add(suc);
            ((GUI)form).ControlProperty = suc;
            ((GUI)form).UpdateOpslaanMenuItem();
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            this.spelers_UserControl1.updateAantalSpelers((int) this.numericUpDown1.Value);
        }

        public void updateNumeric(int count)
        {
            this.numericUpDown1.Value = count;
        }
    }
}
